In [1]:
# %matplotlib inline
import numpy as np, pandas as pd, matplotlib.pyplot as plt, seaborn as sns
import pickle, os, gc, re
from utility import *
BES_data_folder = '../BES_analysis_data/'
Pollbase_folder = create_subdir(BES_data_folder,"Pollbase")
In [13]:
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure, show, output_notebook
from bokeh.layouts import column, row
from bokeh.embed import components
In [3]:
output_notebook()
In [14]:
components()
In [4]:
df = pd.read_csv(Pollbase_folder+"MarkPackPollBase_flat_v5.csv",
parse_dates=['Fieldwork_Start_Date', 'Fieldwork_Finish_Date',
'Fieldwork_Midpoint_Date','Fieldwork_Start_check_date'],index_col="Unnamed: 0")
In [5]:
df.dtypes
Out[5]:
In [ ]:
In [12]:
source = ColumnDataSource(df)
p1 = figure(x_axis_type="datetime",x_axis_label = "Fieldwork_Midpoint_Date",y_axis_label="Con",
plot_width=600, plot_height=250, title="Conservative Voteshare",tools='box_select,lasso_select,pan,wheel_zoom,box_zoom,reset')
p1.scatter('Fieldwork_Midpoint_Date', 'Con', source=source, color='blue')
p2 = figure(x_axis_type="datetime",x_axis_label = "Fieldwork_Midpoint_Date",y_axis_label="Lab",
plot_width=600, plot_height=250, title="Labour Voteshare",tools='box_select,lasso_select,pan,wheel_zoom,box_zoom,reset')
p2.scatter('Fieldwork_Midpoint_Date', 'Lab', source=source, color='red')
p3 = figure(x_axis_type="datetime",x_axis_label = "Fieldwork_Midpoint_Date",y_axis_label="Lab",
plot_width=600, plot_height=250, title="LibDem Voteshare",tools='box_select,lasso_select,pan,wheel_zoom,box_zoom,reset')
p3.scatter('Fieldwork_Midpoint_Date', 'LD', source=source, color='orange')
# Link the x_range of p2 to p1: p2.x_range
p2.x_range = p1.x_range
# Link the y_range of p2 to p1: p2.y_range
p2.y_range = p1.y_range
# Link the x_range of p3 to p1: p3.x_range
p3.x_range = p1.x_range
layout = column(p1,p2,p3)
show(layout)
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: